package com.hzit.manager.api.factory;




import com.hzit.cart.api.domain.Item;
import com.hzit.manager.api.RemoteManagerService;
import com.hzit.manager.api.domain.Content;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 类名：
 * 作者：WF
 * 功能：广告列表查询熔断、降级处理
 */
@Component
public class RemoteContentFallback implements FallbackFactory<RemoteManagerService> {

	@Override
	public RemoteManagerService create(Throwable cause) {

		return new RemoteManagerService() {
			//1. 处理查询广告
			@Override
			public R<List<Content>> findContentsByCategoryId(String id) {
				return R.fail("查询广告列表失败：" + cause.getMessage());
			}
			//2. 处理查询ksu列表
			@Override
			public R<List<Item>> findAllItems() {
				return R.fail("查询sku商品列表失败：" + cause.getMessage());
			}
			//3. 根据spu商品id查询spu商品
			@Override
			public AjaxResult getInfo(Long id) {
				return AjaxResult.error("查询spu商品失败：" + cause.getMessage());
			}

			//4. 根据goodsId查询goosDesc
			@Override
			public AjaxResult getDescInfo(Long goodsId) {
				return AjaxResult.error("查询GoodsDesc商品描述失败：" + cause.getMessage());
			}
			//5. 根据goodsId查询sku商品列表
			@Override
			public R<List<Item>> findItemsByGoodsId(Long goodsId) {
				return R.fail("查询SKU商品列表失败：" + cause.getMessage());
			}


		};
	}
}
